package com.happyfamily.springboot.crowdsourcingplatform.controller.weng;

import com.happyfamily.springboot.crowdsourcingplatform.annotation.OperationLogDetail;
import com.happyfamily.springboot.crowdsourcingplatform.base.result.PageTableRequest;
import com.happyfamily.springboot.crowdsourcingplatform.base.result.Results;
import com.happyfamily.springboot.crowdsourcingplatform.dto.StationFlowDto;
import com.happyfamily.springboot.crowdsourcingplatform.enums.OperationType;
import com.happyfamily.springboot.crowdsourcingplatform.enums.OperationUnit;
import com.happyfamily.springboot.crowdsourcingplatform.model.BankAccount;
import com.happyfamily.springboot.crowdsourcingplatform.model.StationFlow;
import com.happyfamily.springboot.crowdsourcingplatform.service.weng.BackStationFlowService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api-back/stationFlow")
@Slf4j
public class StationFlowController
{
	@Autowired
	BackStationFlowService backStationFlowService;

	@GetMapping("/list")
	@ResponseBody
	@ApiOperation(value = "后台分页获取站务流水", notes = "后台分页获取站务流水", httpMethod = "GET", response = Results.class)
	@OperationLogDetail(detail = "后台分页获取站务流水", level = 1, operationUnit = OperationUnit.ADMIN, operationType = OperationType.SELECT)
	public Results<StationFlow> getAllStationFlowByPage(PageTableRequest request)
	{
		request.countOffset();
		return backStationFlowService.getAllStationFlowByPage(request.getOffset(), request.getLimit());
	}


	@GetMapping("/delete")
	@ResponseBody
	@ApiOperation(value = "后台通过ID删除站务流水记录", notes = "后台通过ID删除站务流水记录", httpMethod = "GET", response = Results.class)
	@OperationLogDetail(detail = "后台删除站务流水记录", level = 4, operationUnit = OperationUnit.ADMIN, operationType = OperationType.DELETE)
	public Results<StationFlow> deleteStationFlow(StationFlowDto stationFlowDto)
	{
		backStationFlowService.deleteStationFlow(stationFlowDto.getSid());
		return Results.success();
	}

	@GetMapping("/findFlowByFuzzy")
	@ResponseBody
	@ApiOperation(value = "后台模糊查询站务流水记录", notes = "后台模糊查询站务流水记录", httpMethod = "GET", response = Results.class)
	@OperationLogDetail(detail = "后台模糊查询站务流水记录", level = 1, operationUnit = OperationUnit.ADMIN, operationType = OperationType.SELECT)
	public Results<StationFlow> getFlowByFuzzy(PageTableRequest requests, String stype, String startTime, String endTime)
	{
		requests.countOffset();
		return backStationFlowService.getFlowByFuzzy(stype, startTime, endTime, requests.getOffset(), requests.getLimit());
	}

	@GetMapping("/getBankPage")
	@ResponseBody
	@ApiOperation(value = "后台获取门户账户情况", notes = "后台获取门户账户情况", httpMethod = "GET", response = Results.class)
	@OperationLogDetail(detail = "后台获取门户账户情况", level = 1, operationUnit = OperationUnit.ADMIN, operationType = OperationType.SELECT)
	public Results<BankAccount> getBankPage(PageTableRequest requests)
	{
		requests.countOffset();
		return backStationFlowService.getBankPage(requests.getOffset(), requests.getLimit());
	}
}
